package com.mzj.saas.jobs.bill.repository;

import com.mzj.saas.jobs.bill.entity.SmartLockCard;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;

import javax.transaction.Transactional;
import java.util.List;

public interface SmartLockCardRepository extends PagingAndSortingRepository<SmartLockCard,Long>, JpaSpecificationExecutor<SmartLockCard> {
	
	SmartLockCard findByLockAuthIdAndTypeAndCardIndex(Long lockAuthId, Integer type, Integer cardIndex);
	
	SmartLockCard findByLockAuthIdAndTypeAndCardIndexNum(Long lockAuthId,Integer type,Integer cardIndexNum);
	
	List<SmartLockCard> findByLockAuthId(Long lockAuthId);
	
	List<SmartLockCard> findByLockAuthIdIn(List<Long> lockAuthIds);
	
	Integer countByLockAuthId(Long lockAuthId);

    SmartLockCard findByLockAuthIdAndType(Long lockAuthId, Integer type);

    List<SmartLockCard> findByLockId(Long lockId);

    @Transactional
    void deleteByLockAuthIdAndType(Long lockAuthId, Integer type);

	int deleteByLockId(Long lockId);

	@Transactional
	void deleteByLockAuthId(Long lockAuthId);
}
